const allRows = [
    {
        name: '黄晓明',
        employeeNo: '001169',
        startDate: '2021-07-01 00:00:00',
        cpfPayName: '',
        singaporeidTypeName: '',
        identityidNo: '',
        prAcquisitionDate: '2021-07-01 00:00:00',
        endDate: '',
        birthday: '',
        departmentName: 's11',
        statusName: '试用',
        // 测试待定
        cpfSubmissionStatus: 0,
        prIssueYear: 0
    },
    {
        name: '刘亦菲',
        employeeNo: '001170',
        startDate: '2021-07-01 00:00:00',
        cpfPayName: '',
        singaporeidTypeName: '',
        identityidNo: '',
        prAcquisitionDate: '',
        endDate: '',
        birthday: '',
        departmentName: '广州研发中心',
        statusName: '试用',
        cpfSubmissionStatus: 1,
        prIssueYear: 1
    },
    {
        name: '周杰伦',
        employeeNo: '000896',
        startDate: '2021-05-26 00:00:00',
        cpfPayName: '',
        singaporeidTypeName: '',
        identityidNo: '',
        prAcquisitionDate: '',
        endDate: '',
        birthday: '',
        departmentName: '胭脂二部',
        statusName: '试用',
        // 已增员状态
        cpfSubmissionStatus: 2,
        prIssueYear: 2
    },
    {
        name: '张三',
        employeeNo: '100896',
        startDate: '2021-05-26 00:00:00',
        cpfPayName: '',
        singaporeidTypeName: '',
        identityidNo: '',
        prAcquisitionDate: '',
        endDate: '',
        birthday: '',
        departmentName: '胭脂二部',
        statusName: '试用',
        // 已增员状态
        cpfSubmissionStatus: 2,
        prIssueYear: 3
    },
    {
        name: '李四',
        employeeNo: '200896',
        startDate: '2021-05-26 00:00:00',
        cpfPayName: '',
        singaporeidTypeName: '',
        identityidNo: '',
        prAcquisitionDate: '',
        endDate: '',
        birthday: '',
        departmentName: '胭脂二部',
        statusName: '试用',
        // 已增员状态
        cpfSubmissionStatus: 2,
        prIssueYear: 4
    }
];

const search = request => {
    const params = request.body;

    const startIndex = (params.pageNo - 1) * params.pageSize;
    const endIndex = params.pageNo * params.pageSize;
    const pages = Math.ceil(allRows.length / params.pageSize);
    // console.log('params:', params);
    // console.log('startIndex:', startIndex);
    // console.log('endIndex:', endIndex);
    const rows = allRows.length <= startIndex ? null : allRows.slice(startIndex, endIndex);
    console.log('rows:', rows);

    return {
        code: 10000,
        data: {
            total: allRows.length,
            pages,
            pageNo: params.pageNo,
            pageSize: params.pageSize,
            records: rows
        }
    };
};

export default {
    'POST x/api/finance/salary/v1/setting/cpf/employee/list': (req, res) => {
        console.log(`${req.url}:使用mock数据`);
        res.json(search(req));
    }
};
